package com.takeeasy.platform.util;

import java.io.File;
import java.io.FilenameFilter;

public class ActionNameFileFilter implements FilenameFilter {

	private String contract;

	public String getContract() {
		return contract;
	}

	public void setContract(String contract) {
		this.contract = contract;
	}

	@Override
	public boolean accept(File dir, String name) {
		String dirPath = dir.getAbsolutePath();
		String filePath = dirPath + FileUtil.FILE_SEPARATOR + name;
		File file = new File(filePath);
		if (file.isDirectory()) {
			return true;
		}
		if (contract == null) {
			if (name.lastIndexOf("Action.class") != -1) {
				return true;
			}
		} else {
			if (name.contains(this.getContract())) {
				return true;
			}
		}
		return false;
	}

}
